﻿using daonaite.core.Attribute;
using daonaite.DAL.system;
using daonaite.Model.system.menu;
using daonaite.Model.system.roleMenu;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace daonaite.services.system
{
    [AutoLoad]
    public class menuService
    {
        private readonly D_menu menucz;

        public menuService(D_menu menucz)
        {
            this.menucz = menucz;
        }

        /// <summary>
        /// 获取角色菜单
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public async Task<List<sys_menu>?> getrolemenuAsync(int[] roleIds)
        {
            return await menucz.getrolemenuAsync(roleIds);
        }


        /// <summary>
        /// 获取菜单
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public async Task<List<sys_menu>?> getmenuAsync(Dto_menu data)
        {
            return await menucz.getmenuAsync(data);
        }

        /// <summary>
        /// 获取菜单与按钮
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public async Task<List<sys_menu>?> getmenuandbuttonAsync()
        {

            return await menucz.getmenuandbuttonAsync();
        }

        /// <summary>
        /// 查询菜单信息
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task<List<sys_menu>> selectAsync(Dto_menu data)
        {
            
            return await menucz.selectAsync(data);
        }

        /// <summary>
        /// 添加菜单
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task<int> add(sys_menu data)
        {
            return await menucz.add(data);
        }

        /// <summary>
        /// 根据id获取菜单信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<sys_menu> getAsync(int id)
        {
            return await menucz.getAsync(id);
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task<int> updateAsync(sys_menu data)
        {
            return await menucz.updateAsync(data);
        }

        /// <summary>
        /// 查询菜单按钮
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<List<sys_menu>> selectButtonAsync(int id)
        {
            return await menucz.selectButtonAsync(id);
        }

        /// <summary>
        /// 删除菜单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<int> delete(int id)
        {
            return await menucz.delete(id);
        }

        /// <summary>
        /// 一键添加按钮, 增删查改
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task onkeyadd(int id)
        {
            await menucz.onkeyadd(id);
        }

    }
}
